/**
 ***********************************************************************************************************************
 * Copyright (c) 2025
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 *
 * @file        loop.h
 *
 * @revision
 *          Date:           2025/5/16
 *          Author:         Damon
 *          Notes:          
 * @description
 *          
 *     
 ***********************************************************************************************************************
 */

#ifndef LOOP_H
#define LOOP_H

#define MAX_LIST_LEN            16

typedef void (*LoopFunc)(void);

extern LoopFunc init_fun_list[MAX_LIST_LEN];
extern LoopFunc loop_fun_list[MAX_LIST_LEN];
extern int fun_init_cnt;
extern int fun_loop_cnt;

#define INIT_FUNCTION(name)     \
void name();                \
void __attribute__((constructor)) init_##name() {   \
init_fun_list[fun_init_cnt++] = &name;     \
}   \
void name()

#define LOOP_FUNCTION(name)     \
void name();                \
void __attribute__((constructor)) loop_##name() {   \
loop_fun_list[fun_loop_cnt++] = &name;     \
}   \
void name()

void init_func(void);
void loop_func(void);

#endif //LOOP_H
